/**
 * <copyright>
 * </copyright>
 *

 */
package hu.bme.mit.androtext.gui.androGuiLang.impl;

import hu.bme.mit.androtext.gui.androGuiLang.AndroGuiLangPackage;
import hu.bme.mit.androtext.gui.androGuiLang.AndroGuiRoot;
import hu.bme.mit.androtext.gui.androGuiLang.RootLayout;
import hu.bme.mit.androtext.gui.androGuiLang.StringEntry;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Andro Gui Root</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link hu.bme.mit.androtext.gui.androGuiLang.impl.AndroGuiRootImpl#getName <em>Name</em>}</li>
 *   <li>{@link hu.bme.mit.androtext.gui.androGuiLang.impl.AndroGuiRootImpl#getRootlayout <em>Rootlayout</em>}</li>
 *   <li>{@link hu.bme.mit.androtext.gui.androGuiLang.impl.AndroGuiRootImpl#getEntries <em>Entries</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AndroGuiRootImpl extends MinimalEObjectImpl.Container implements AndroGuiRoot
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getRootlayout() <em>Rootlayout</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRootlayout()
   * @generated
   * @ordered
   */
  protected RootLayout rootlayout;

  /**
   * The cached value of the '{@link #getEntries() <em>Entries</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEntries()
   * @generated
   * @ordered
   */
  protected EList<StringEntry> entries;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected AndroGuiRootImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return AndroGuiLangPackage.Literals.ANDRO_GUI_ROOT;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroGuiLangPackage.ANDRO_GUI_ROOT__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RootLayout getRootlayout()
  {
    return rootlayout;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetRootlayout(RootLayout newRootlayout, NotificationChain msgs)
  {
    RootLayout oldRootlayout = rootlayout;
    rootlayout = newRootlayout;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AndroGuiLangPackage.ANDRO_GUI_ROOT__ROOTLAYOUT, oldRootlayout, newRootlayout);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRootlayout(RootLayout newRootlayout)
  {
    if (newRootlayout != rootlayout)
    {
      NotificationChain msgs = null;
      if (rootlayout != null)
        msgs = ((InternalEObject)rootlayout).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AndroGuiLangPackage.ANDRO_GUI_ROOT__ROOTLAYOUT, null, msgs);
      if (newRootlayout != null)
        msgs = ((InternalEObject)newRootlayout).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AndroGuiLangPackage.ANDRO_GUI_ROOT__ROOTLAYOUT, null, msgs);
      msgs = basicSetRootlayout(newRootlayout, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroGuiLangPackage.ANDRO_GUI_ROOT__ROOTLAYOUT, newRootlayout, newRootlayout));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<StringEntry> getEntries()
  {
    if (entries == null)
    {
      entries = new EObjectContainmentEList<StringEntry>(StringEntry.class, this, AndroGuiLangPackage.ANDRO_GUI_ROOT__ENTRIES);
    }
    return entries;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__ROOTLAYOUT:
        return basicSetRootlayout(null, msgs);
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__ENTRIES:
        return ((InternalEList<?>)getEntries()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__NAME:
        return getName();
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__ROOTLAYOUT:
        return getRootlayout();
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__ENTRIES:
        return getEntries();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__NAME:
        setName((String)newValue);
        return;
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__ROOTLAYOUT:
        setRootlayout((RootLayout)newValue);
        return;
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__ENTRIES:
        getEntries().clear();
        getEntries().addAll((Collection<? extends StringEntry>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__NAME:
        setName(NAME_EDEFAULT);
        return;
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__ROOTLAYOUT:
        setRootlayout((RootLayout)null);
        return;
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__ENTRIES:
        getEntries().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__ROOTLAYOUT:
        return rootlayout != null;
      case AndroGuiLangPackage.ANDRO_GUI_ROOT__ENTRIES:
        return entries != null && !entries.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //AndroGuiRootImpl
